﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using DXApplicationTangche.service;
using mendian;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.样品管理.样品下单新.service
{
    public class 样品下单Service
    {
        /// <summary>
        /// 查询所有外包客户
        /// </summary>
        /// <returns></returns>
        public static List<CustomerChooseInfoDTO> getOutSourcingCustomer()
        {
            return
                FunctionHelper.JsonDeserialization<List<CustomerChooseInfoDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/customer/getOutSourcingCustomer"
                        )
                    ); 
        }
        /// <summary>
        /// 创建委外客户
        /// </summary>
        /// <param name="customerCreateDTO"></param>
        /// <returns></returns>
        public static CustomerChooseInfoDTO createCustomer(CustomerCreateDTO customerCreateDTO)
        {
            return
                FunctionHelper.JsonDeserialization<CustomerChooseInfoDTO>(
                    RestCall.PostHttp(
                        URL.接口url + "/customer/createCustomer",
                        FunctionHelper.JsonSerialization(customerCreateDTO)
                        )
                    );
        }
        public static void post项目(string formID, DTO备注项目详情 DTO备注项目)
        {
            RestCall.PostHttp(
                        URL.接口url + "/sample/saveSampleRecord?sampleId=" + formID,
                        FunctionHelper.JsonSerialization(DTO备注项目)
                        );
        }

        public static void 上传文件(string id, OpenFileDialog ofd)
        {
            FileService.UploadRequest(
                    URL.接口url + "/sample/uploadSampleFile?id=" + id,
                    ofd.FileName,
                    Path.GetFileName(ofd.FileName),
                    "multipartFile"
                    );
        }
        public static List<DTO备注项目> get备注项目()
        {
            return
                FunctionHelper.JsonDeserialization<List<DTO备注项目>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/sample/getSampleItemAll"
                        )
                    );
        }
        public static List<DTO备注项目详情> get备注项目详情(string formID)
        {
            return
                FunctionHelper.JsonDeserialization<List<DTO备注项目详情>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/sample/findSampleRecordBySampleId?sampleId=" + formID 
                        )
                    );
        }
        public static String getformIdByOrderId(string orderId)
        {
            return
                RestCall.httpGetMethod(
                        URL.接口url + "/sample/getSampleIdByOrderId?orderId=" + orderId
                        );
        }
    }

    public class CustomerCreateDTO
    {
        public int customerId { get; set; }//
        public String customerFirstName { get; set; }//
        public String customerLastName { get; set; }//
        public String nick { get; set; }//
        public String tel { get; set; }//
        public String mobile { get; set; }//
        public int defaultAddrFlag { get; set; }//
        public int addressType { get; set; }//
        public String sexCd { get; set; }//
        public String addressCountryCd { get; set; }//
        public String addressProvinceCd { get; set; }//
        public String addressCityCd { get; set; }//
        public String addressDistrict { get; set; }//
        public String addressDetail { get; set; }//
        public String businessName { get; set; }//
        public String companyAddress { get; set; }//
        public String companyName { get; set; }//
        public String eMailUrl { get; set; }//
        public DateTime birthDate { get; set; }//
        public String zipCode { get; set; }//
        public String remarks { get; set; }//
        public String validateCode { get; set; }//
        public String customerStatus { get; set; }//
        public DateTime deadLine { get; set; }//
        public int usable { get; set; }//
        public int sended { get; set; }//
        public int deleteFlag{get;set;}//
        public int version {get;set;}//
        public DateTime createDate { get; set; }//
        public DateTime updateDate { get; set; }//
        public int createUser { get; set; }//
        public int updateUser { get; set; }//
        public int assistantFlag { get; set; }//
        public CustomerCreateDTO()
        {
            this.deleteFlag = 0;
            this.version = 1;
        }

        public CustomerCreateDTO(string customerFirstName, string mobile)
        {
            this.customerFirstName = customerFirstName;
            this.mobile = mobile;
            this.deleteFlag = 0;
            this.version = 1;
        }
    }

public class CustomerChooseInfoDTO
    {
        public String id { get; set; }
        public String customerId { get; set; }//客户id
        public String customerName { get; set; }//客户名称
        public String countId { get; set; }//客户量体id
        public String mobile { get; set; }//手机
        public String createDate { get; set; }//创建时间
        public String customerCountName { get; set; }//客户量体名称
        public String addressId { get; set; }//地址id
        public List<CustomerFitRDTO> customerFitRDTOS { get; set; }//客户量体
        public CustomerOrderCommitDTO customerOrderCommitDTO { get; set; }//收货信息
        public CustomerChooseInfoDTO()
        {

        }
    }
    public class CustomerFitRDTO
    {
        public int customerId { get; set; }//
        public String customerFirstName { get; set; }//
        public String customerLastName { get; set; }//
        public String nick { get; set; }//
        public String tel { get; set; }//
        public String mobile { get; set; }//
        public int defaultAddrFlag { get; set; }//
        public int addressType { get; set; }//
        public String sexCd { get; set; }//
        public String addressCountryCd { get; set; }//
        public String addressProvinceCd { get; set; }//
        public String addressCityCd { get; set; }//
        public String addressDistrict { get; set; }//
        public String addressDetail { get; set; }//
        public String businessName { get; set; }//
        public String companyAddress { get; set; }//
        public String companyName { get; set; }//
        public String eMailUrl { get; set; }//
        public DateTime birthDate { get; set; }//
        public String zipCode { get; set; }//
        public String remarks { get; set; }//
        public String validateCode { get; set; }//
        public String customerStatus { get; set; }//
        public DateTime deadLine { get; set; }//
        public int usable { get; set; }//
        public int sended { get; set; }//
        public int deleteFlag {get;set;}//
        public int version{get;set;}//
        public DateTime createDate { get; set; }//
        public DateTime updateDate { get; set; }//
        public int createUser { get; set; }//
        public int updateUser { get; set; }//
        public int assistantFlag { get; set; }//
        public CustomerFitRDTO()
        {
            this.deleteFlag = 0;
            this.version = 1;
        }
    }

    public class DTO备注项目
    {
        public String id { get; set; }    //  项目ID
        public String name { get; set; }  //  项目名
        public Boolean unique { get; set; } //  是否唯一
        public String memo { get; set; }    //  备注
        public DTO备注项目()
        {

        }

    }
    public class DTO备注项目详情
    {
        public String id { get; set; }  //  id
        //  图片信息
        public String fileName { get; set; }    //  文件名
        public String filePath { get; set; }    //  文件路径
        //  基础信息
        public String sampleItemId { get; set; }    //  项目ID
        public String sampleItemName { get; set; }  //  项目名
        public Boolean unique { get; set; } //  是否唯一
        public String memo { get; set; }    //  备注
        public DTO备注项目详情()
        {

        }
    }
}
